<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-row>
        <el-col :span="6">
          <el-form-item label="学校名称" prop="schoolName">
            <el-input
              v-model="queryParams.schoolName"
              placeholder="请输入学校名称"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="项目名称" prop="demandName">
            <el-input
              v-model="queryParams.demandName"
              placeholder="请输入项目名称"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>

        <el-col :span="9">
          <el-form-item label="申报时间">
            <el-date-picker
              clearable
              size="small"
              v-model="queryParams.selectStartTime"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              range-separator="至"
              type="daterange"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="是否确认">
            <el-select
              v-model="queryParams.confirm"
              placeholder="请选择项目状态"
              size="small"
            >
              <el-option
                v-for="item in confirmStateOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="handleQuery"
              >搜索</el-button
            >
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
              >重置</el-button
            >
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['archives:project:add']"
          >新增</el-button
        >
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:demand:edit']"
          >修改</el-button
        >
      </el-col> -->
      <!-- <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:demand:remove']"
          >删除</el-button
        >
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['archives:project:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="demandList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="id" align="center" prop="establishDemandId" /> -->
      <el-table-column
        label="学校名称"
        align="center"
        prop="schoolName"
        width="200"
      />
      <el-table-column
        label="项目名称"
        align="center"
        prop="demandName"
        width="200"
      />
      <!-- <el-table-column label="项目内容" align="center" prop="demandContent" /> -->
      <el-table-column label="投资概算/万元" align="center" prop="money" />
      <el-table-column label="土地证" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="ytudi"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="tudi"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.tudi }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="项目建议书" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yxiangmu"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="xiangmu"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.xiangmu }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="社会稳定风险评估" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yshehui"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="shehui"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.shehui }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="可行性研究报告" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="ykexing"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="kexing"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.kexing }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="地形测绘" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="ydixing"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="dixing"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.dixing }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="设计" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="ysheji"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="sheji"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.sheji }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="岩土工程勘察" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yyantu"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="yantu"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.yantu }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="环境影响报告书编制" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yhuanjing"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="huanjing"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.huanjing }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="建设工程规划" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yjianshe"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="jianshe"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.jianshe }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="初设及投资计划" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="ychushe"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="chushe"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.chushe }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="绿建评价" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="ylvjian"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="lvjian"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.lvjian }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="交通影响评价" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yjiaotong"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="jiaotong"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.jiaotong }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="审图" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yshentu"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="shentu"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.shentu }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="预算书" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yyusuan"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="yusuan"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.yusuan }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="财政评审" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="ycaizheng"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="caizheng"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.caizheng }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="招标" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yzhaobiao"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="zhaobiao"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.zhaobiao }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="工程中标通知书" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="ygongcheng"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="gongcheng"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.gongcheng }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="监理中标通知书" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yjianli"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="jianli"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.jianli }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="质检备案" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yzhijian"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="zhijian"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.zhijian }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="安全备案" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yanquan"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="anquan"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.anquan }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="消防备案" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yxiaofang"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="xiaofang"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.xiaofang }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="人防备案" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yrenfang"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="renfang"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.renfang }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="施工证" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yshigong"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="shigong"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.shigong }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="深基坑观测" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yshenji"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="shenji"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.shenji }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="材料检测" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="ycailiao"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="cailiao"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.cailiao }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="沉降观测" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="ychenjiang"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="chenjiang"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.chenjiang }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="基础施工" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yjichu"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="jichu"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.jichu }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="主体结构及二次结构施工" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yzhuti"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="zhuti"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.zhuti }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="装饰装修工程施工" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yzhuangshi"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="zhuangshi"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.zhuangshi }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="外线及景观工程施工" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="ywaixian"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="waixian"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.waixian }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="设备采购安装" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yshebei"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="shebei"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.shebei }}</span>
          </template>
        </el-table-column>
      </el-table-column>

      <el-table-column label="竣工验收" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yjungong"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="jungong"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.jungong }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="结算报告" align="center">
        <el-table-column
          label="预计完成时间"
          align="center"
          prop="yjiesuan"
          width="110"
        />
        <el-table-column
          label="完成时间"
          align="center"
          prop="jiesuan"
          width="110"
        >
          <template slot-scope="scope">
            <span class="finish-time">{{ scope.row.jiesuan }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column
        label="第一次支付金额/万元"
        align="center"
        prop="firstMoney"
      />
      <el-table-column
        label="第一次支付时间"
        align="center"
        prop="firstTime"
        width="110"
      />
      <el-table-column
        label="后期支付金额/万元"
        align="center"
        prop="laterMoney"
      />
      <el-table-column
        label="尾款支付金额/万元"
        align="center"
        prop="lastMoney"
      />
      <el-table-column
        label="尾款支付时间"
        align="center"
        prop="lastTime"
        width="110"
      />

      <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
        width="110"
      />
      <el-table-column
        label="是否确认"
        align="center"
        prop="confirm"
        width="110"
      >
        <template slot-scope="scope">
          <el-tag v-if="scope.row.confirm === 0" type="info">未确认</el-tag>
          <el-tag v-if="scope.row.confirm === 1">已确认</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="320"
        fixed="right"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-success"
            @click="confirmBtnClick(scope.row)"
            v-hasPermi="['archives:project:confirm']"
            >确认</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-folder-remove"
            @click="recallBtnClick(scope.row)"
            v-hasPermi="['archives:project:recall']"
            >撤回</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleUpdate(scope.row, 0)"
            v-hasPermi="['archives:project:look']"
            >查看</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row, 1)"
            v-hasPermi="['archives:project:edit']"
            :disabled="scope.row.confirm === 1"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['archives:project:delete']"
            :disabled="scope.row.confirm === 1"
            >删除</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-download"
            @click="handleDownload(scope.row)"
            v-hasPermi="['archives:project:download']"
            >下载</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改基建类项目需求申请对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="50%"
      append-to-body
      :close-on-click-modal="false"
      v-dialogDrag
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="项目名称" prop="demandName">
          <el-input v-model="form.demandName" placeholder="请输入项目名称" />
        </el-form-item>
        <el-form-item label="项目内容" prop="demandContent">
          <!-- <editor v-model="form.demandContent" :min-height="192" /> -->
          <el-input
            type="textarea"
            placeholder="请输入项目内容"
            v-model="form.demandContent"
            :rows="5"
            :maxlength="1000"
            show-word-limit
          >
          </el-input>
        </el-form-item>
        <el-form-item label="投资概算" prop="money">
          <el-input v-model="form.money" placeholder="请输入投资概算/万元" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      :title="editFormTitle"
      :visible.sync="editDialogVisible"
      width="80%"
      @close="editFormClose"
      :close-on-click-modal="false"
      v-dialogDrag
    >
      <el-tabs v-model="activeName">
        <el-tab-pane label="基本信息" name="0">
          <el-form
            ref="editBaseInfo"
            :model="form"
            :rules="rules"
            label-width="80px"
          >
            <el-form-item label="项目名称" prop="demandName">
              <el-input
                v-model="form.demandName"
                placeholder="请输入项目名称"
                :disabled="isLookBtnClick"
              />
            </el-form-item>
            <el-form-item label="项目内容" prop="demandContent">
              <!-- <editor v-model="form.demandContent" :min-height="192" /> -->
              <el-input
                type="textarea"
                placeholder="请输入项目内容"
                v-model="form.demandContent"
                :rows="5"
                :disabled="isLookBtnClick"
                :maxlength="1000"
                show-word-limit
              >
              </el-input>
            </el-form-item>
            <el-form-item label="投资概算" prop="money">
              <el-input
                v-model="form.money"
                placeholder="请输入投资概算/万元"
                :disabled="isLookBtnClick"
              />
            </el-form-item>
            <el-form-item class="save-item">
              <el-button
                type="primary"
                size="small"
                icon="el-icon-folder-checked"
                @click="saveBaseInfo"
                class="save-btn"
                >保 存</el-button
              >
            </el-form-item>
          </el-form>
        </el-tab-pane>
        <el-tab-pane label="文件上传" name="1">
          <el-tabs
            tab-position="left"
            v-model="uploadActiveName"
            type="border-card"
            class="upload-tabs"
          >
            <el-tab-pane label="土地证" name="1">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="1"
                stage-name="tudi"
                ref="editUpload1"
                :is-disabled="isLookBtnClick"
                title="土地证"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="项目建议书" name="2">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="2"
                stage-name="xiangmu"
                ref="editUpload2"
                :is-disabled="isLookBtnClick"
                title="项目建议书"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="社会稳定风险评估" name="3">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="3"
                stage-name="shehui"
                ref="editUpload3"
                :is-disabled="isLookBtnClick"
                title="社会稳定风险评估"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="可行性研究报告" name="4">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="4"
                stage-name="kexing"
                ref="editUpload4"
                :is-disabled="isLookBtnClick"
                title="可行性研究报告"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="地形测绘" name="5">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="5"
                stage-name="dixing"
                ref="editUpload5"
                :is-disabled="isLookBtnClick"
                title="地形测绘"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="设计" name="6">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="6"
                stage-name="sheji"
                ref="editUpload6"
                :is-disabled="isLookBtnClick"
                title="设计"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="岩土工程勘察" name="7">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="7"
                stage-name="yantu"
                ref="editUpload7"
                :is-disabled="isLookBtnClick"
                title="岩土工程勘察"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="环境影响报告书编制" name="8">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="8"
                stage-name="huanjing"
                ref="editUpload8"
                :is-disabled="isLookBtnClick"
                title="环境影响报告书编制"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="建设工程规划" name="9">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="9"
                stage-name="jianshe"
                ref="editUpload9"
                :is-disabled="isLookBtnClick"
                title="建设工程规划"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="初设及投资计划" name="10">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="10"
                stage-name="chushe"
                ref="editUpload10"
                :is-disabled="isLookBtnClick"
                title="初设及投资计划"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="绿建评价" name="11">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="11"
                stage-name="lvjian"
                ref="editUpload11"
                :is-disabled="isLookBtnClick"
                title="绿建评价"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="交通影响评价" name="12">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="12"
                stage-name="jiaotong"
                ref="editUpload12"
                :is-disabled="isLookBtnClick"
                title="交通影响评价"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="审图" name="13">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="13"
                stage-name="shentu"
                ref="editUpload13"
                :is-disabled="isLookBtnClick"
                title="审图"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="预算书" name="14">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="14"
                stage-name="yusuan"
                ref="editUpload14"
                :is-disabled="isLookBtnClick"
                title="预算书"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="财政评审" name="15">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="15"
                stage-name="caizheng"
                ref="editUpload15"
                :is-disabled="isLookBtnClick"
                title="财政评审"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="招标" name="16">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="16"
                stage-name="zhaobiao"
                ref="editUpload16"
                :is-disabled="isLookBtnClick"
                title="招标"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="工程中标通知书" name="17">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="17"
                stage-name="gongcheng"
                ref="editUpload17"
                :is-disabled="isLookBtnClick"
                title="工程中标通知书"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="监理中标通知书" name="18">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="18"
                stage-name="jianli"
                ref="editUpload18"
                :is-disabled="isLookBtnClick"
                title="监理中标通知书"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="质检备案" name="19">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="19"
                stage-name="zhijian"
                ref="editUpload19"
                :is-disabled="isLookBtnClick"
                title="质检备案"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="安全备案" name="20">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="20"
                stage-name="anquan"
                ref="editUpload20"
                :is-disabled="isLookBtnClick"
                title="安全备案"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="消防备案" name="21">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="21"
                stage-name="xiaofang"
                ref="editUpload21"
                :is-disabled="isLookBtnClick"
                title="消防备案"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="人防备案" name="22">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="22"
                stage-name="renfang"
                ref="editUpload22"
                :is-disabled="isLookBtnClick"
                title="人防备案"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="施工证" name="23">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="23"
                stage-name="shigong"
                ref="editUpload23"
                :is-disabled="isLookBtnClick"
                title="施工证"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="深基坑观测" name="24">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="24"
                stage-name="shenji"
                ref="editUpload24"
                :is-disabled="isLookBtnClick"
                title="深基坑观测"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="材料检测" name="25">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="25"
                stage-name="cailiao"
                ref="editUpload25"
                :is-disabled="isLookBtnClick"
                title="材料检测"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="沉降观测" name="26">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="26"
                stage-name="chenjiang"
                ref="editUpload26"
                :is-disabled="isLookBtnClick"
                title="沉降观测"
              ></project-edit-form>
            </el-tab-pane>

            <el-tab-pane label="基础施工" name="30">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="30"
                stage-name="jichu"
                ref="editUpload30"
                :is-disabled="isLookBtnClick"
                title="基础施工"
                :is-show-hetong="false"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="主体结构及二次结构施工" name="31">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="31"
                stage-name="zhuti"
                ref="editUpload31"
                :is-disabled="isLookBtnClick"
                title="主体结构及二次结构施工"
                :is-show-hetong="false"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="装饰装修工程施工" name="32">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="32"
                stage-name="zhuangshi"
                ref="editUpload32"
                :is-disabled="isLookBtnClick"
                title="装饰装修工程施工"
                :is-show-hetong="false"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="外线及景观工程施工" name="33">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="33"
                stage-name="waixian"
                ref="editUpload33"
                :is-disabled="isLookBtnClick"
                title="外线及景观工程施工"
                :is-show-hetong="false"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="设备采购安装" name="34">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="34"
                stage-name="shebei"
                ref="editUpload34"
                :is-disabled="isLookBtnClick"
                title="设备采购安装"
                :is-show-hetong="false"
              ></project-edit-form>
            </el-tab-pane>

            <el-tab-pane label="竣工验收" name="27">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="27"
                stage-name="jungong"
                ref="editUpload27"
                :is-disabled="isLookBtnClick"
                title="竣工验收"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="结算报告" name="28">
              <project-edit-form
                :open-edit-form="editDialogVisible"
                :project-id="uploadProjectId"
                :stage-id="28"
                stage-name="jiesuan"
                ref="editUpload28"
                :is-disabled="isLookBtnClick"
                title="结算报告"
              ></project-edit-form>
            </el-tab-pane>
            <el-tab-pane label="资金支付" name="29">
              <el-form
                ref="fundPayForm"
                :model="fundPayForm"
                label-width="120px"
                :rules="rules"
                class="upload-form"
              >
                <h1 class="title">资金支付</h1>
                <el-form-item label="第一次支付金额">
                  <el-input
                    v-model="fundPayForm.firstMoney"
                    placeholder="单位/万元"
                    :disabled="isLookBtnClick"
                  />
                </el-form-item>
                <el-form-item label="第一次支付时间">
                  <el-date-picker
                    v-model="fundPayForm.firstTime"
                    type="date"
                    placeholder="请选择时间"
                    value-format="yyyy-MM-dd"
                    :disabled="isLookBtnClick"
                  >
                  </el-date-picker>
                </el-form-item>
                <el-form
                  ref="fundPayUploadForm"
                  :model="fundPayUploadForm"
                  label-width="120px"
                >
                  <el-form-item label="附件">
                    <project-upload
                      :upload-address="fundPayUploadForm.uploadAddress1"
                      :type="1"
                      ref="fundPayUploadForm1"
                      :auth-disabled="isLookBtnClick"
                      :project-id="uploadProjectId"
                    ></project-upload>
                  </el-form-item>
                </el-form>
                <el-form-item label="后期支付金额">
                  <el-input
                    v-model="fundPayForm.laterMoney"
                    placeholder="单位/万元"
                    :disabled="isLookBtnClick"
                  />
                </el-form-item>
                <el-form
                  ref="fundPayUploadForm"
                  :model="fundPayUploadForm"
                  label-width="120px"
                >
                  <el-form-item label="附件">
                    <project-upload
                      :upload-address="fundPayUploadForm.uploadAddress2"
                      :type="2"
                      ref="fundPayUploadForm2"
                      :auth-disabled="isLookBtnClick"
                      :project-id="uploadProjectId"
                    ></project-upload>
                  </el-form-item>
                </el-form>
                <el-form-item label="备注">
                  <el-input
                    type="textarea"
                    placeholder="请输入内容"
                    v-model="fundPayForm.remarks"
                    :rows="5"
                    :disabled="isLookBtnClick"
                    :maxlength="500"
                    show-word-limit
                  >
                  </el-input>
                </el-form-item>
                <el-form-item label="尾款支付金额">
                  <el-input
                    v-model="fundPayForm.lastMoney"
                    placeholder="单位/万元"
                    :disabled="isLookBtnClick"
                  />
                </el-form-item>
                <el-form-item label="尾款支付时间">
                  <el-date-picker
                    v-model="fundPayForm.lastTime"
                    type="date"
                    placeholder="请选择时间"
                    value-format="yyyy-MM-dd"
                    :disabled="isLookBtnClick"
                  >
                  </el-date-picker>
                </el-form-item>
                <el-form
                  ref="fundPayUploadForm"
                  :model="fundPayUploadForm"
                  label-width="120px"
                >
                  <el-form-item label="附件">
                    <project-upload
                      :upload-address="fundPayUploadForm.uploadAddress3"
                      :type="3"
                      ref="fundPayUploadForm3"
                      :auth-disabled="isLookBtnClick"
                      :project-id="uploadProjectId"
                    ></project-upload>
                  </el-form-item>
                </el-form>
                <el-form-item class="save-item">
                  <div class="save-btn">
                    <el-button
                      v-if="isLookBtnClick"
                      type="primary"
                      size="small"
                      icon="el-icon-download"
                      @click="downloadFundPayAllFile"
                      >批量下载</el-button
                    >
                    <el-button
                      type="primary"
                      size="small"
                      icon="el-icon-folder-checked"
                      @click="saveFundPayForm"
                      :disabled="isLookBtnClick"
                      >保 存</el-button
                    >
                  </div>
                </el-form-item>
              </el-form>
            </el-tab-pane>
          </el-tabs>
        </el-tab-pane>
      </el-tabs>
      <span slot="footer" class="dialog-footer">
        <!-- <el-button @click="editFormClose">取 消</el-button> -->
        <!-- <el-button type="primary" @click="submitEditForm">确 定</el-button> -->
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {
  listDemand,
  getDemand,
  delDemand,
  addDemand,
  updateDemand,
  getProjectBaseInfo,
  updateBaseInfo,
  getUpdateInfo,
  confirmProject,
  recallProject,
} from "@/api/archives/project";
import ProjectUpload from "@/views/archives/components/ProjectUpload";
import ProjectEditForm from "@/views/archives/components/ProjectEditForm";

export default {
  name: "Demand",
  components: {
    ProjectUpload,
    ProjectEditForm,
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 基建类项目需求申请表格数据
      demandList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        demandName: null,
        demandContent: null,
        // money: null,
        userId: null,
        deptId: null,
        schoolName: null,
        confirm: null,
        selectStartTime: null,
        selectEndTime: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        demandName: [
          { required: true, message: "项目名称不能为空", trigger: "blur" },
        ],
        demandContent: [
          { required: true, message: "项目内容不能为空", trigger: "blur" },
        ],
        money: [
          { required: true, message: "投资概算不能为空", trigger: "blur" },
        ],
      },
      activeName: "0",
      editFormTitle: "",
      editDialogVisible: false,
      uploadActiveName: "1",
      uploadProjectId: 0,
      isLookBtnClick: false,
      confirmStateOptions: [
        {
          value: 0,
          label: "未确认",
        },
        {
          value: 1,
          label: "已确认",
        },
      ],
      fundPayForm: {
        firstMoney: null,
        firstTime: null,
        laterMoney: null,
        remarks: null,
        lastMoney: null,
        lastTime: null,
      },
      fundPayUploadForm: {
        uploadAddress1: null,
        uploadAddress2: null,
        uploadAddress3: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询基建类项目需求申请列表 */
    getList() {
      this.loading = true;
      listDemand(this.queryParams).then((response) => {
        // console.log(response);
        this.demandList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        // establishDemandId: null,
        demandName: null,
        demandContent: null,
        money: null,
        // createTime: null,
        // userId: null,
        // deptId: null,
        // schoolName: null,
        // confirm: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.queryParams.selectEndTime =
        this.queryParams.selectStartTime && this.queryParams.selectStartTime[1];
      this.queryParams.selectStartTime =
        this.queryParams.selectStartTime && this.queryParams.selectStartTime[0];
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.confirm = null;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.establishDemandId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "新增项目";
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (!valid) return;
        addDemand(this.form).then((res) => {
          this.getList();
          this.open = false;
          this.$modal.msgSuccess("添加成功");
        });
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row, num) {
      if (num === 0) {
        this.editFormTitle = "查看项目";
        this.isLookBtnClick = true;
      }
      if (num === 1) {
        this.editFormTitle = "修改项目";
      }
      this.editDialogVisible = true;
      this.uploadProjectId = row.establishDemandId;
      setTimeout(() => {
        for (let i = 1; i <= 34; i++) {
          i !== 29 &&
            this.$refs[`editUpload${i}`].getInfo(row.establishDemandId, i);
        }
        this.$refs.fundPayUploadForm1.queryFile(row.establishDemandId, 29, 1);
        this.$refs.fundPayUploadForm2.queryFile(row.establishDemandId, 29, 2);
        this.$refs.fundPayUploadForm3.queryFile(row.establishDemandId, 29, 3);
      }, 500);
      this.fundPayUploadForm.uploadAddress1 = `${process.env.VUE_APP_BASE_URL}/archives/establishFiles/upload/${row.establishDemandId}/29/1`;
      this.fundPayUploadForm.uploadAddress2 = `${process.env.VUE_APP_BASE_URL}/archives/establishFiles/upload/${row.establishDemandId}/29/2`;
      this.fundPayUploadForm.uploadAddress3 = `${process.env.VUE_APP_BASE_URL}/archives/establishFiles/upload/${row.establishDemandId}/29/3`;
      getProjectBaseInfo(row.establishDemandId).then((res) => {
        // console.log(res);
        this.form = res.data;
        this.fundPayForm = res.data;
      });
    },
    // 关闭修改对话框
    editFormClose() {
      !this.isLookBtnClick && this.getList();
      this.editDialogVisible = false;
      this.isLookBtnClick = false;
      this.form = {
        demandName: null,
        demandContent: null,
        money: null,
      };
      this.fundPayForm = {
        firstMoney: null,
        firstTime: null,
        laterMoney: null,
        remarks: null,
        lastMoney: null,
        lastTime: null,
      };
      new Array(28).forEach((item, index) => {});
      for (let i = 1; i <= 34; i++) {
        if (i !== 29) {
          this.$refs[`editUpload${i}`].editUploadForm = {
            establishDemandId: null,
            stageId: null,
            yjfinishTime: null,
            finishTime: null,
            involve: false,
            stageName: null,
          };
          this.$refs[`editUpload${i}`].awaitDeledtFileList1 = [];
          this.$refs[`editUpload${i}`].awaitDeledtFileList2 = [];
          this.$refs[`editUpload${i}`].awaitDeledtFileList3 = [];
          this.$refs[`editUpload${i}`].isSave = false;
        }
      }
      this.uploadActiveName = "1";
      this.activeName = "0";
      this.resetForm("editBaseInfo");
    },
    // 保存基本信息
    saveBaseInfo() {
      this.$refs.editBaseInfo.validate((valid) => {
        if (!valid) return;
        updateBaseInfo(this.form).then((res) => {
          this.$message.success("保存成功！");
          this.getList();
        });
      });
    },
    saveFundPayForm() {
      updateBaseInfo(this.fundPayForm).then((res) => {
        this.$message.success("保存成功！");
        this.getList();
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      this.$confirm("你确定要删除这一项吗, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          delDemand(row.establishDemandId).then((res) => {
            this.getList();
            this.$message({
              type: "success",
              message: "删除成功!",
            });
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    // 确认
    confirmBtnClick(row) {
      this.$confirm("确认之后用户将不可修改, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          confirmProject(row.establishDemandId).then((res) => {
            this.getList();
            this.$message({
              type: "success",
              message: "操作成功!",
            });
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已撤销!",
          });
        });
    },
    // 撤回
    recallBtnClick(row) {
      this.$confirm("撤回后该项目可以修改, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          recallProject(row.establishDemandId).then((res) => {
            this.getList();
            this.$message({
              type: "success",
              message: "操作成功!",
            });
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已撤销!",
          });
        });
    },
    handleDownload(row) {
      this.$download.zip(
        `/archives/establishFiles/downloadAll/${row.establishDemandId}`,
        `jijian__${row.schoolName}_${row.demandName}_${new Date().getTime()}`
      );
    },
    downloadFundPayAllFile() {
      this.$download.zip(
        `/archives/establishFiles/downloadAllFiles/${this.uploadProjectId}/29`,
        `资金支付_${new Date().getTime()}`
      );
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "/archives/establishDemand/eexport",
        {
          ...this.queryParams,
        },
        `jijian_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>

<style scoped>
.upload-tabs {
  height: 70vh;
}

.save-item {
  position: relative;
  height: 36px;
}
.save-btn {
  position: absolute;
  right: 0;
}
.upload-form {
  position: relative;
  height: 60vh;
  overflow: auto !important;
  padding-right: 10px;
}
.title {
  color: #606266;
  font-weight: bold;
  /* position: absolute;
  left: 10px; */
  text-align: left;
}
.finish-time {
  color: #67c23a;
}
.el-input {
  width: 220px;
}
.el-textarea {
  width: 50%;
}
</style>
